package o;

import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import com.huawei.appgallery.downloadengine.api.SessionDownloadTask;
import com.huawei.appgallery.downloadengine.api.SplitTask;
import com.huawei.appgallery.packagemanager.api.bean.ManagerTask;
import com.huawei.appgallery.serverreqkit.api.listener.IServerCallBack;
import java.util.ArrayList;
import java.util.List;

public class dwr extends Handler {
    public static final Handler ˋ = new dwr(ContentManager.getInstant().getContext().getMainLooper());

    public dwr(Looper looper) {
        super(looper);
    }

    public void handleMessage(Message message) {
        Object obj = message.obj;
        if (obj instanceof ManagerTask) {
            ManagerTask managerTask = (ManagerTask) obj;
            int i = message.arg1;
            Logger.ˎ("LocalePackageProcessHandler", "LocalePackageProcessHandler" + " status view type:" + i + ",pkg:" + managerTask.packageName);
            switch (i) {
                case 4:
                    ˊ(message, managerTask);
                    return;
                case 5:
                    ˏ(message, managerTask);
                    return;
                default:
                    return;
            }
        }
    }

    private void ˊ(Message message, ManagerTask managerTask) {
        if (managerTask.ॱॱ instanceof SessionDownloadTask) {
            int i = message.arg2;
            SessionDownloadTask sessionDownloadTask = (SessionDownloadTask) managerTask.ॱॱ;
            dwm.ॱ().ˎ(sessionDownloadTask);
            ˋ(sessionDownloadTask, i, 1);
        }
    }

    private void ˏ(Message message, ManagerTask managerTask) {
        if (managerTask.ॱॱ instanceof SessionDownloadTask) {
            SessionDownloadTask sessionDownloadTask = (SessionDownloadTask) managerTask.ॱॱ;
            dwm.ॱ().ˎ(sessionDownloadTask);
            ˋ(sessionDownloadTask, message.arg2, 0);
        }
    }

    private void ˋ(SessionDownloadTask sessionDownloadTask, int i, int i2) {
        IServerCallBack o_cgf = new cgf(false);
        cvt o_cgj = new cgj();
        o_cgj.ˏ(1);
        o_cgj.ˋ(sessionDownloadTask.ˊˊ());
        if (i2 == 1) {
            o_cgj.ॱ(String.valueOf(i));
        }
        o_cgj.ˎ(i2);
        o_cgj.ˎ(sessionDownloadTask.ʾ() + "");
        o_cgj.ॱ(sessionDownloadTask.ॱᐝ());
        List arrayList = new ArrayList();
        for (SplitTask splitTask : sessionDownloadTask.ᐝˊ()) {
            String ॱˎ = splitTask.ॱˎ();
            o_cgj.ˊ(ॱˎ);
            o_cgj.ˏ(splitTask.ॱᐝ());
            if (!arrayList.contains(ॱˎ)) {
                arrayList.add(ॱˎ);
                cfw.ˎ(o_cgj, o_cgf);
            }
        }
    }
}
